<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
  defined('_JEXEC') or die('Retricted Access');
  $editor = &JFactory::getEditor();
?>

<script type="text/javascript" language="javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;

	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
	if ( pressbutton == 'save' || pressbutton == 'apply' ){
		
		if(form.name.value == '' ){
		    alert('<?php echo JText::_('Template name could not be empty')?>');
			form.name.focus();
			return;
		}	
		
		if(form.title.value == '' ){
		    alert('<?php echo JText::_('Title could not be empty')?>');
			form.name.focus();
			return;
		}	
		

		if(form.subject.value == '' ){
		    alert('<?php echo JText::_('Subject could not be empty')?>');
			form.subject.focus();
			return;
		}		
		
		submitform( pressbutton );
	}					
	else {
		submitform( pressbutton );
	}
}
function insertVariable(el){
    if (!el.selectedIndex) return;
    txt = el.form.elements.content;
    txt.value = txt.value + el.options[ el.selectedIndex ].value;
    el.selectedIndex = -1;
}
function formReload(frm, reload){
    frm.elements.reload.value = reload;
    frm.submit();
}
</script>
<form name="adminForm" action="index.php" method="post">
    <table width="100%">
    	
		<tr>
	
		<td width="80%" valign="top">
			<div style="width:100%;">
				
				<fieldset>
					<legend><?php echo JText::_('Email Properties')?></legend>
					
					<table class="admintable" width="100%">
						<tbody>
							<tr>
								<td width="20%" align="right" class="key">
									<?php echo JText::_('Status')?>: 
								</td>
					
								<td width="80%">
									<?php 
	            						if ($this->item->system){
	            							if($this->item->modified){?>
	            								<font color="Red"><?php echo JText::_('Modified')?></font> 
	            								<?php echo JText::_('by')?> 
	            								<?php 
	            									$temp = JFactory::getUser($this->item->creator);
	            								?>
	            								<b><?php echo $temp->username?></b> 
	            								<?php echo JText::_('at')?> 
	            								<?php echo date('Y-m-d H:i:s', $this->item->update_date)?>
	            							 <?php }else{?>
	            							 	<?php echo JText::_('Not Modified')?> <img src="components/com_jajobboard/images/notmodified.gif" title="<?php echo JText::_('Not Modified')?>" alt="<?php echo JText::_('Not Modified')?>"/>
	            							 <?php }?>
	            							 
	            						<?php } else{?>
											<img src="components/com_jajobboard/images/usercreated.gif" title="<?php echo JText::_('User Created')?>" alt="<?php echo JText::_('User Created')?>"/>
	            						 <?php }
	            							
	            					?> 
									 
								</td>
							</tr>
							<tr>
								<td width="20%" align="right" class="key"><?php echo JText::_('Available language(s)')?>: </td>
					
								<td width="80%"> <?php echo $this->listlangs_available?> </td>
							</tr>
							<tr>
								<td width="20%" align="right" class="key"><?php echo JText::_('Action')?>: </td>
								<td width="80%" bgcolor="White"> 
									<?php if ($this->item->system && $this->item->modified){?>
										<a href="index.php?option=com_jajobboard&view=jaemail&task=restore&cid[]=<?php echo $this->item->id?>"><?php echo JText::_('Restore to default')?></a> | 
									<?php }?>
										<a href="index.php?option=com_jajobboard&view=jaemail&task=show_duplicate&cid=<?php echo $this->item->id?>"><?php echo JText::_('Copy to another language')?></a>
									<?php if (!$this->item->system){?>
										<a onclick="return confirm('<?php echo JText::_('Are your sure to delete this email template?')?>')" href="index.php?option=com_jajobboard&view=jaemail&task=remove&cid[]=<?php echo $this->item->id?>"> | <?php echo JText::_('Delete')?> </a>
									<?php }?>
									
								</td>
							</tr>
						</tbody>
					</table>
				</fieldset>
				

				<fieldset>
				<legend><?php if($this->item->id) echo JText::_('Edit mail template'); else echo JText::_('Add Email Template');?></legend>
    
				<table class="admintable">		        	
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'Template name' ); ?>:
						</td>
						
						<td width="80%">
							<input class="inputbox" type="text" name="name" size="50" maxlength="255" value="<?php echo $this->item->name; ?>" <?php if($this->item->name) echo "disabled";?> /> 
							<font color="Red">*</font>
						</td>				
		        	</tr>
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'Title' ); ?>:
						</td>
						
						<td width="80%">
							<input class="inputbox" type="text" name="title" size="50" maxlength="255" value="<?php echo $this->item->title; ?>" /> 
							<font color="Red">*</font>
						</td>				
		        	</tr>
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'Language' ); ?>:
						</td>
						<td width="80%">
						
							<?php echo $this->languages; ?>
						</td>
		        	</tr> 
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'Email Template Group' ); ?>:
						</td>
						<td width="80%">
								<?php echo $this->group; ?>
						</td>
		        	</tr> 
		        	<?php if ($this->item->paymentconfig_id) {?>
		        	<tr>
						<td class="key">
							<label for="paymentconfig_id">
								<?php echo JText::_( 'Payment Gateway' ); ?>:
							</label>						
						</td>
						<td valign="top" colspan="3">
							<?php
								echo $this->paysys;
							?>
						</td>
					</tr>
					<?php } ?>
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'Subscription ID' ); ?>:
							<br/>
							<small><?php echo JText::_('Empty for default');?></small>
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="subscription_id" size="50" maxlength="255" value="<?php echo $this->item->subscription_id; ?>" />
						</td>
		        	</tr>
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'From Address' ); ?>:
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="EmailFromAddress" size="50" maxlength="255" value="<?php echo $this->item->EmailFromAddress; ?>" />
						</td>
		        	</tr>   
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'From name' ); ?>:
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="EmailFromName" size="50" maxlength="255" value="<?php echo $this->item->EmailFromName; ?>" />
						</td>
		        	</tr>   
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'Subject' ); ?>:
						</td>
						<td width="80%">
							<input class="inputbox" type="text" name="subject" size="50" maxlength="255" value="<?php echo $this->item->subject; ?>" />
							<font color="Red">*</font>
						</td>
		        	</tr>   
		        	       	
		        	
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'Published' ); ?>:
						</td>
						<td width="80%">
							<?php echo $this->published?>
						</td>
		        	</tr>
		        	
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'Content' ); ?>:										
						</td>
						<td width="80%">
							<textarea name="content" cols="80" rows="20" id="content"><?php echo html_entity_decode($this->item->content, ENT_QUOTES);?></textarea>
							<?php
								//echo $this->editor->display( 'content', $this->item->content, '550', '300', '60', '20', array('pagebreak', 'readmore') ) ;
								//echo $this->editor->display( 'content',  htmlspecialchars($this->item->content, ENT_QUOTES), '550', '300', '60', '20', array('pagebreak', 'readmore') ) ;
							?>
						</td>
		        	</tr>
		        	<tr>
		        		<td class="key" width="20%" align="right">
							<?php echo JText::_( 'E-Mail Variables' ); ?>:
						</td>
						<td width="80%" bgcolor="White">
							<?php echo $this->tags?>
						</td>
		        	</tr>
		    	</table>
		     </fieldset>    
			</div>
		</td>
	</tr>
	</table>
	<?php if(!$this->item->id){?>
	<input type="hidden" name="name" value="<?php echo $this->item->name; ?>"/>
	<?php }?>
	<!--<input type="hidden" name="paymentconfig_id" value="<?php echo JRequest::getInt('paysys_id',0); ?>" />-->
	<input type="hidden" name="id" value="<?php echo $this->item->id; ?>" />
	<input type="hidden" name="cid" value="<?php echo $this->item->id; ?>" />
	<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
	<input type="hidden" name="view" value="jaemail" />
	<input type="hidden" name="task" value="" />
	<?php echo JHTML::_( 'form.token' ); ?>	
 </form>